<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>HashChange试验</title>
</head>
<body>
  <div class="main">
    <p>前端三驾马车</p>
    <ul>
      <li><a href="#angular">angular</a></li>
      <li><a href="#vue">vue</a></li>
      <li><a href="#react">react</a></li>
    </ul>
  </div>
  <script>
    window.onload = function() {
      // hash变化时触发
      window.onhashchange = function(opt) {
        console.log('hash changed：', opt, window.location.hash)
      }
    }
  </script>
</body>
</html>